package com.zhuss.team.invest;

import com.zhuss.bean.bo.team.invest.CareInvestListBo;
import com.zhuss.bean.bo.team.invest.DetailInvestBo;
import com.zhuss.bean.bo.team.invest.SearchInvestBo;
import com.zhuss.bean.vo.team.invest.CareInvestListVo;
import com.zhuss.common.AbstractBo;
import com.zhuss.common.ListVo;
import com.zhuss.common.ReadService;
import com.zhuss.common.SelectVo;
import com.zhuss.core.processor.EnumConfig;
import com.zhuss.exception.WpsException;
import com.zhuss.team.db.entity.InvestQuestion;
import com.zhuss.team.processor.InvestQuestionRead;
import com.zhuss.team.processor.InvestRead;
import com.zhuss.team.processor.QuestionRead;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: zhushanshuo
 * @Date: 2020/3/3 14:25
 */
@Component("investReadService")
public class InvestReadService implements ReadService<Object,Object> {

    @Autowired
    @Qualifier("investRead")
    private InvestRead investRead;

    @Autowired
    @Qualifier("questionRead")
    private QuestionRead questionRead;

    @Autowired
    @Qualifier("investQuestionRead")
    private InvestQuestionRead investQuestionRead;

    @Autowired
    @Qualifier("enumConfig")
    private EnumConfig enumConfig;

    @Override
    public Object detail(Object o) throws WpsException {
        DetailInvestBo bo = (DetailInvestBo) o;
        Object result = investRead.detail(bo.getInvestId());
        return result;
    }

    @Override
    public Object list(Object o) throws WpsException {
        SearchInvestBo bo = (SearchInvestBo) o;
        Object result = investRead.list(bo);
        return result;
    }

    /**
     * 获取问题列表
     * @param bo
     * @return
     * @throws WpsException
     */
    public Object careInvestList(CareInvestListBo bo) throws WpsException {
        Long investId = bo.getInvestId();
        Integer area = bo.getArea();
        CareInvestListVo result = new CareInvestListVo();
        result.setQuestionIdList((List<Long>)investQuestionRead.listQuestionId(investId));
        result.setQuestionList((List<ListVo>)questionRead.listQuestion(area));
        return result;
    }

    /**
     * 获取问卷类型
     * @param o
     * @return
     * @throws WpsException
     */
    public Object getInvestGroup(AbstractBo o) throws WpsException {
        List<SelectVo> selectList = enumConfig.listSelectInvestGroup(o.getConcurrentArea());
        return selectList;
    }

    /**
     * 获取问卷下拉框
     * @param o
     * @return
     * @throws WpsException
     */
    public Object getInvestList(AbstractBo o) throws WpsException {
        Object result = investRead.getInvestList(o.getConcurrentArea());
        return result;
    }
}
